package berkekeydb;

import java.io.File;
import java.util.Properties;

import com.sleepycat.bind.EntryBinding;
import com.sleepycat.bind.serial.SerialBinding;
import com.sleepycat.bind.serial.StoredClassCatalog;
import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.collections.StoredSortedMap;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;

public class T1 {
	public static void main(String[] args) {
		Properties properties = new Properties();
		EnvironmentConfig envconfig = new EnvironmentConfig(properties);
		envconfig.setTransactional(false);
		envconfig.setAllowCreate(true);
		Environment env = new Environment(new File("F:/test"), envconfig);
		createdb(env);
		close(env);
	}

	@SuppressWarnings("unused")
	static void createdb(Environment env) {
		String dbName = "test.db";
		DatabaseConfig config = new DatabaseConfig();
		config.setAllowCreate(true);
		config.setTransactional(false);
		config.setSortedDuplicates(false);
		Database db = env.openDatabase(null , "classDB" , config);
		
		StoredClassCatalog catalog = new StoredClassCatalog(db);
		TupleBinding<String> keybinding = TupleBinding.getPrimitiveBinding(String.class);
		
		SerialBinding<String> valueBinding = new SerialBinding<String>(catalog, String.class);
		Database store = env.openDatabase(null, dbName, config);
		
		EntryBinding<String> keyList = new SerialBinding<String>(catalog, String.class);
		EntryBinding<String> valueEntityBinding = new SerialBinding<String>(catalog, String.class);
		StoredSortedMap<String, String> map = new StoredSortedMap<String, String>(store, keyList, valueEntityBinding, true);
		
	}

	static void close(Environment env) {
		env.sync();
		env.close();
		env = null;
	}

}
